
#include "CreditsState.h"
#include "../../SGD Wrappers/CSGD_Direct3D.h"
#include "../../SGD Wrappers/CSGD_DirectInput.h"
#include "../../SGD Wrappers/CSGD_XAudio2.h"
#include "MainMenuState.h"
#include "Game.h"
#include "BitmapFont.h"
#include <cassert>
#include "tinyxml.h"


//Singleton accessor
CreditsState* CreditsState::GetInstance(void)
{
	static CreditsState instance;
	return &instance;
}


//Constructor
CreditsState::CreditsState(void)
{
}


//Destructor
CreditsState::~CreditsState(void)
{
}


//Enter
void CreditsState::Enter(void)
{
	offsetY = 400.0f;
}


//Exit
void CreditsState::Exit (void)
{
}


//Input
bool CreditsState::Input(void)
{
	CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();
	CSGD_XAudio2* XA = CSGD_XAudio2::GetInstance();

	//Ignore input when alt is down
	if (pDI->KeyDown(DIK_LALT) == true || pDI->KeyDown(DIK_RALT) == true)
		return true;

	if( pDI->KeyPressed(DIK_RETURN) || pDI->KeyPressed(DIK_ESCAPE) || 
		pDI->MouseButtonPressed(0) || pDI->MouseButtonPressed(1))
	{
		Game::GetInstance()->ChangeState(MainMenuState::GetInstance());
		return true;
	}

	return true;
}


//Update
void CreditsState::Update(float dt)
{
	if (offsetY > 0.0f)
		offsetY -= 120 * dt;
}


//Render
void CreditsState::Render(void)
{
	CSGD_XAudio2* XA = CSGD_XAudio2::GetInstance();

	CBitmapFont* pFont = Game::GetInstance()->GetFont();
	pFont->Draw(_T("Credits"), 260, 220 + (int)offsetY, 1.0f, 
		D3DCOLOR_ARGB(255, 255, 255, 255));

	pFont->Draw( _T("Full Sail University"),
		210, 400 + (int)offsetY, 0.8f, D3DCOLOR_ARGB(255, 255, 255, 255));
}
